package com.itheima.config;

//TODO:构建数据库连接池对象DataSource

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;

import javax.sql.DataSource;
import javax.swing.*;

/**
 * @author ChaunceyZhang
 */
@Configuration
@PropertySources({
        @PropertySource("classpath:jdbc.properties")
})
public class JdbcConfig {
    @Value("${jdbc.driver}")
    private String driver;

    @Value("${jdbc.url}")
    private String url;


    @Value("${jdbc.username}")
    private String username;

    @Value("${jdbc.password}")
    private String password;

   /* @Value("${jdbc.gender}")
    private Integer gender;


    @Value("${jdbc.idCard}")
    private String idCard;

    @Value("${jdbc.fromAddress}")
    private String fromAddress;

    @Value("${jdbc.toAddress}")
    private String toAddress;

    @Value("${jdbc.startTime}")
    private String startTime;*/

    /**
     * 引入德鲁伊管理数据库
     */
    @Bean
    public DataSource dataSource(){
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(driver);
        druidDataSource.setUrl(url);
        druidDataSource.setUsername(username);
        druidDataSource.setPassword(password);

        return druidDataSource;
    }
}